<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <common-head1></common-head1>
        <common-head2></common-head2>
       
    </div>




    <template id="ap">
        <div @click='fn1'>我是1组件</div>
    </template>
    <template id="apo">
        <div >我是2组件</div>
    </template>
    <script src="./vue.js"></script>
    <script>
        const bus=new Vue()
        const CommonHead1={
            template:'#ap',
            methods:{
                fn1(){
                    bus.$emit('d2','哈哈')
                }
            }
        }
        const CommonHead2={
            template:'#apo',
            mounted(){
                bus.$on('d2',(res)=>{
                    console.log(res)
                })
            }
        }
        Vue.component('CommonHead1',CommonHead1)
        Vue.component('CommonHead2',CommonHead2)
        const vm=new Vue({
            el:'#app'
        })
    </script>
</body>

</html>